package org.example.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MinioConfig {

  @Value(value = "${minio.host}")
  private String host;

  @Value(value = "${minio.access-key}")
  private String accessKey;

  @Value(value = "${minio.secret-key}")
  private String secretKey;

  @Bean
  public MinioClient minioClient() {
    try {
      return new MinioClient(host, accessKey, secretKey);
    } catch (Exception e) {
      // 捕获并处理可能抛出的任何异常
      throw new RuntimeException("Failed to create MinIO client", e);
    }
  }
}
